package me.huanmeng.heater.bot;

import me.huanmeng.heater.main.HeaterMain;

import java.util.logging.Level;

/**
 * 2021/9/27<br>
 * Heater<br>
 *
 * @author huanmeng_qwq
 */
public interface MessageHelper {
    /**
     * 输出debug信息
     *
     * @param messages 信息
     */
    default void debug(Object... messages) {
        if (HeaterMain.getInstance().isDebug()) {
            log(Level.INFO, messages);
        }
    }

    /**
     * 输出Log
     *
     * @param level    级别
     * @param messages 信息
     */
    default void log(Level level, Object... messages) {
        if (HeaterMain.getInstance().getLogger() != null) {
            for (Object message : messages) {
                if (message instanceof Throwable) {
                    ((Throwable) message).printStackTrace();
                }else{
                    HeaterMain.getInstance().getLogger().log(level, String.valueOf(message));
                }
            }
        } else {
            for (Object message : messages) {
                System.out.println(message);
            }
        }
    }
}
